package com.guoxin.chapter3.waitnotify.pipereaderwriter;

import java.io.IOException;
import java.io.PipedReader;

public class ReadData {
	public void readMethod(PipedReader reader){
		try {
			System.out.println("read:");
			char[] charArray = new char[20];
			int readLength = reader.read(charArray);
			while(readLength != -1){
				String newData = new String(charArray, 0, readLength);
				System.out.print(newData);
				readLength = reader.read(charArray);
			}
			System.out.println();
			reader.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
